<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>身份证真实性检验 - xhemj</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/xhemj/static@latest/backup/css/form.min.css">
</head>
<body>
<script src="https://cdn.jsdelivr.net/gh/xhemj/static@latest/js/get-querystring.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/xhemj/IDVerify@2.0/IDVerify.min.js"></script>
<script src="https://cdn.staticfile.org/vConsole/3.3.4/vconsole.min.js"></script>
<script>
/* -------------------------------- 
 * IDVerify 身份证真实性检验
 * ©2020 xhemj
 *------------------------------- */
var number = querystring("id");
var backcode = "";
var name = "IDVerify";
	var oid1 = number.slice(0,1)*7;
	var oid2 = number.slice(1,2)*9;
	var oid3 = number.slice(2,3)*10;
	var oid4 = number.slice(3,4)*5;
	var oid5 = number.slice(4,5)*8;
	var oid6 = number.slice(5,6)*4;
	var oid7 = number.slice(6,7)*2;
	var oid8 = number.slice(7,8)*1;
	var oid9 = number.slice(8,9)*6;
	var oid10 = number.slice(9,10)*3;
	var oid11 = number.slice(10,11)*7;
	var oid12 = number.slice(11,12)*9;
	var oid13 = number.slice(12,13)*10;
	var oid14 = number.slice(13,14)*5;
	var oid15 = number.slice(14,15)*8;
	var oid16 = number.slice(15,16)*4;
	var oid17 = number.slice(16,17)*2;
	var oidplus = oid1*1+oid2*1+oid3*1+oid4*1+oid5*1+oid6*1+oid7*1+oid8*1+oid9*1+oid10*1+oid11*1+oid12*1+oid13*1+oid14*1+oid15*1+oid16*1+oid17*1;
	var oiddivision = oidplus%11
	if (oiddivision == 0) {
		var code = 1
	};
	if (oiddivision == 1) {
		var code = 0
	};
	if (oiddivision == 2) {
		var code = "X"
	};
	if (oiddivision == 3) {
		var code = 9
	};
	if (oiddivision == 4) {
		var code = 8
	};
	if (oiddivision == 5) {
		var code = 7
	};
	if (oiddivision == 6) {
		var code = 6
	};
	if (oiddivision == 7) {
		var code = 5
	};
	if (oiddivision == 8) {
		var code = 4
	};
	if (oiddivision == 9) {
		var code = 3
	};
	if (oiddivision == 10) {
		var code = 2
	};
	if (number.length == 18){
		if (number.slice(17,18).toUpperCase() == code) {
			var backcode = "该身份证号正确";
		}else {
			var backcode = "该身份证号错误";
		};
	}
	if (number.length == 17){
		var backcode = "身份证校验码为："+code;
	}
	if (number.length != 17) {
		if (number.length != 18) {
			if (number != "") {
			console.error(name+":"+"身份证格式或位数不符合规定。ID card format or digits do not meet the requirements.");
			var backcode = "身份证格式或位数不符合规定"
			}
		}
	}
var date = number.slice(6,7)+number.slice(7,8)+number.slice(8,9)+number.slice(9,10)+"年"+number.slice(10,11)+number.slice(11,12)+"月"+number.slice(12,13)+number.slice(13,14)+"日";
var p = IDProvince(number);
var c = IDCity(number);
if (querystring("vc") == "true") {
var vconsole = new VConsole();
}
</script>
<div class="container">
<form class="cd-form floating-labels">
<legend>身份证真实性检验</legend>
<fieldset>
<div class="icon">
<label class="cd-label" for="id">请输入待检测的身份证号</label>
<script>
document.write("<input type=\"text\" id=\""+Math.ceil(Math.random()*Math.ceil(Math.random()*99999999))+"\" value=\""+number+"\" name=\"id\" required class=\"user\" AUTOCOMPLETE=\"OFF\"><\/input>");
</script>
</div>
<input type="submit" value="检验">
</fieldset>
<script>
if (number != "") {
	document.write("<div class=\"error-message\"><p>"+backcode+"<\/p><\/div>");
}
</script>

<script>
if (number != "") {
	if (backcode != "身份证格式或位数不符合规定"){
		document.write("<fieldset>");
		document.write("<h3>身份证详细信息：<\/h3>");
		document.write("<label class=\"cd-label\" for=\"p\">省份</label>");
		document.write("<input type=\"text\" id=\""+Math.ceil(Math.random()*Math.ceil(Math.random()*99999999))+"\" value=\""+p+"\" name=\"p\" AUTOCOMPLETE=\"OFF\"><\/input>");
		document.write("<\/br>");
		document.write("<label class=\"cd-label\" for=\"p\">城市</label>");
		document.write("<input type=\"text\" id=\""+Math.ceil(Math.random()*Math.ceil(Math.random()*99999999))+"\" value=\""+c+"\" name=\"c\" AUTOCOMPLETE=\"OFF\"><\/input>");
		document.write("<\/br>");
		document.write("<label class=\"cd-label\" for=\"p\">生日</label>");
		document.write("<input type=\"text\" id=\""+Math.ceil(Math.random()*Math.ceil(Math.random()*99999999))+"\" value=\""+date+"\" name=\"date\" AUTOCOMPLETE=\"OFF\"><\/input>");
		document.write("<\/fieldset>");
	}
};
</script>
<center><label class="cd-label">本项目完全开源，可以到<a href="https://github.com/xhemj/books/blob/master/page/id-card.html" target="_blank">这里</a>来查看源代码，若不放心在线使用，可以到源代码处下载源代码后离线进行使用</br>原理：根据身份证前17为数字通过身份证校验码的算法算出校验码后与原校验码进行匹配，若匹配则为正确身份证</label></br>
<label class="cd-label">©2020 xhemj</label></center>
</form>
</div>
</body>
</html>
